package com.meitianhui.convenitenbuy.module.store.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.meitianhui.convenitenbuy.R;
import com.meitianhui.convenitenbuy.module.store.model.StoreInfo;
import com.meitianhui.convenitenbuy.util.GlideUtils;

import java.util.HashMap;
import java.util.List;

/*
  Created by amy on 2017/11/29.
 */

public class StoreSearchAdapter extends BaseQuickAdapter<StoreInfo.Convenient,BaseViewHolder> {
    HashMap<String, String> mDoc_url = new HashMap<>();
    public StoreSearchAdapter( @Nullable List<StoreInfo.Convenient> data) {
        super(R.layout.item_store_search, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, StoreInfo.Convenient item) {
        helper.setText(R.id.tv_store_search_name,item.getStores_name());
        if (TextUtils.isEmpty(item.getDistance())){
            helper.setText(R.id.tv_store_search_distance,"");
        }else {
            helper.setText(R.id.tv_store_search_distance,item.getDistance()+"米");
        }
        helper.setText(R.id.tv_store_search_address,item.getAddress());

        if (TextUtils.isEmpty(item.getBusiness_type_desc())){
            //隐藏
            helper.setVisible(R.id.tv_store_search_type,false);
        }else {
            helper.setVisible(R.id.tv_store_search_type,true);
            helper.setText(R.id.tv_store_search_type,item.getBusiness_type_desc());
        }

        GlideUtils.setRectImage(mContext,mDoc_url.get(item.getNeighbor_pic_path()),R.mipmap.icon_default_picture,R.mipmap.icon_default_picture,helper.getView(R.id.iv_store_search_picture));

    }

    public void setPicUrl(HashMap<String, String> doc_url) {
        mDoc_url = doc_url;
    }
}
